package CanvaWeb.CanvaWeb.Controller;

import CanvaWeb.CanvaWeb.Service.WordService;
import CanvaWeb.CanvaWeb.pojo.Word;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/game")
public class WordController {

    @Autowired
    private WordService wordService;

    @GetMapping("/words")
    public ResponseEntity<List<Word>> getWords(@RequestParam(defaultValue = "5") int count) {
        List<Word> words = wordService.getRandomWords(count);
        return ResponseEntity.ok(words);
    }
}
